package com.mhc.haval.manager.impl;

import com.mhc.haval.api.dto.WorkflowDTO;
import com.mhc.haval.api.service.WorkFlowConfigService;
import com.mhc.haval.dal.mapper.ext.WorkflowExtMapper;
import com.mhc.haval.dal.model.WorkflowDO;
import com.mhc.suzuki.constant.IsDeletedEnum;
import com.subaru.common.util.BeanCopierUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by HMJ on 2017/8/24.
 */
@Slf4j
@RestController
public class WorkFlowConfigServiceImpl implements WorkFlowConfigService {

    @Autowired
    private WorkflowExtMapper workflowExtMapper;

    /**
     * 根据员工所属部门ID查找所属流程
     *
     * @param companyNo
     * @param applyType
     * @return
     */
    @Override
    public WorkflowDTO selectWorkFlow(String companyNo, int applyType) {
        Map<String, Object> paramMap = new HashMap<>(64);
        paramMap.put("companyNo", companyNo);
        paramMap.put("applyType", applyType);
        paramMap.put("isDeleted", IsDeletedEnum.NORMAL.getCode());
        WorkflowDO workflowDO = workflowExtMapper.queryByWorkflow(paramMap);
        return BeanCopierUtil.convert(workflowDO, WorkflowDTO.class);
    }
}
